<head>
  
    <link type="text/css" rel="stylesheet" href="/webServiceProjectBoosGiroud2013-war/faces/javax.faces.resource/style.css?ln=css" />
   

    <title>Find latitude and longitude with Google Maps</title>
    <script
        src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAgrj58PbXr2YriiRDqbnL1RSqrCjdkglBijPNIIYrqkVvD1R4QxRl47Yh2D_0C1l5KXQJGrbkSDvXFA"
    type="text/javascript"></script>
    <script type="text/javascript">
        function load() {
            if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                var center = new GLatLng(48.89364, 2.33739);
                map.setCenter(center, 15);
                geocoder = new GClientGeocoder();
                var marker = new GMarker(center, {
                    draggable : true
                });
                map.addOverlay(marker);
                document.getElementById("lat").innerHTML = center.lat().toFixed(5);
                document.getElementById("lng").innerHTML = center.lng().toFixed(5);

                GEvent.addListener(marker, "dragend", function() {
                    var point = marker.getPoint();
                    map.panTo(point);
                    document.getElementById("lat").innerHTML = point.lat().toFixed(
                    5);
                    document.getElementById("lng").innerHTML = point.lng().toFixed(
                    5);

                });

                GEvent.addListener(map, "moveend", function() {
                    map.clearOverlays();
                    var center = map.getCenter();
                    var marker = new GMarker(center, {
                        draggable : true
                    });
                    map.addOverlay(marker);
                    document.getElementById("lat").innerHTML = center.lat()
                    .toFixed(5);
                    document.getElementById("lng").innerHTML = center.lng()
                    .toFixed(5);

                    GEvent.addListener(marker, "dragend", function() {
                        var point = marker.getPoint();
                        map.panTo(point);
                        document.getElementById("lat").innerHTML = point.lat()
                        .toFixed(5);
                        document.getElementById("lng").innerHTML = point.lng()
                        .toFixed(5);

                    });

                });

            }
        }

        function showAddress(address) {
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            if (geocoder) {
                geocoder.getLatLng(address, function(point) {
                    if (!point) {
                        alert(address + " not found");
                    } else {
                        
                         document.getElementById("adr").innerHTML =address;
                        document.getElementById("lat").innerHTML = point.lat()
                        .toFixed(5);
                        document.getElementById("lng").innerHTML = point.lng()
                        .toFixed(5);
                        map.clearOverlays()
                        map.setCenter(point, 14);
                        var marker = new GMarker(point, {
                            draggable : true
                        });
                        map.addOverlay(marker);

                        GEvent.addListener(marker, "dragend", function() {
                            var pt = marker.getPoint();
                            map.panTo(pt);
                            document.getElementById("lat").innerHTML = pt.lat()
                            .toFixed(5);
                            document.getElementById("lng").innerHTML = pt.lng()
                            .toFixed(5);
                        });

                        GEvent.addListener(map, "moveend", function() {
                            map.clearOverlays();
                            var center = map.getCenter();
                            var marker = new GMarker(center, {
                                draggable : true
                            });
                            map.addOverlay(marker);
                            document.getElementById("lat").innerHTML = center.lat()
                            .toFixed(5);
                            document.getElementById("lng").innerHTML = center.lng()
                            .toFixed(5);

                            GEvent.addListener(marker, "dragend", function() {
                                var pt = marker.getPoint();
                                map.panTo(pt);
                                document.getElementById("lat").innerHTML = pt.lat()
                                .toFixed(5);
                                document.getElementById("lng").innerHTML = pt.lng()
                                .toFixed(5);
                            });

                        });

                    }
                });
            }
        }
        function valider() {
            var lat = document.getElementById("lat").innerHTML;
            var lng = document.getElementById("lng").innerHTML;
             var adr = document.getElementById("adr").innerHTML;
		
            window.location="http://localhost:8080/webServiceProjectBoosGiroud2013-war/faces/VendeurCreerUnMagasin.xhtml?lattitude="+lat+"&longitude="+lng;		
        }
    </script>

</head>







<body onload="load()" onunload="GUnload()">
    <div id="entete">
        <table class="noStyle">
            <tr class="noStyle">
                <td class="noStyle" width="60%">
                    <div class="titreAppli"><h1>Trouver adresse</h1></div>
                </td>
                <td class="noStyle" width="40%">
                    <img src="ressources/user.png" alt="logoUser" border="0" class="imgUser" />
                </td>
            </tr>
        </table>
    </div>
    <div id="centre">
     
           

            <div id="centreLeft">
                <center><h2>Menu d'admin</h2></center>
                <ul>
                    <li>
                        <script type="text/javascript" src="/webServiceProjectBoosGiroud2013-war/faces/javax.faces.resource/jsf.js?ln=javax.faces"></script>
                        <a href="#" onclick="mojarra.jsfcljs(document.getElementById('testeFormConnectOKadmin'),{'testeFormConnectOKadmin:j_idt33':'testeFormConnectOKadmin:j_idt33'},'');return false">Afficher les magasins</a> </li>
                </ul>     
            </div>

            <div id="centreRight">
                <form action="" onsubmit="showAddress(this.address.value); return false">
                    <p>
                        <input type="text" size="60" name="address" 
                               value="1645 Route des Lucioles, 06410 Biot" />


                        <input type="submit"
                               value="Search!" />
                    </p>
                </form>

        

                <table bgcolor="#FFFFCC" width="300">
                    <tr>
                        <td><b>Latitude</b></td>
                        <td><b>Longitude</b></td>
                        <td><b>Adresse</b></td>
                    </tr>
                    <tr>
                        <td id="lat"></td>
                        <td id="lng"></td>
                        <td id="adr">1645 Route des Lucioles, 06410 Biot</td>
                    </tr>
                    <tr>
                    <a style="color: red; size: 20px; background-color: blue;" onclick="valider()">VALIDER</a>
                    </tr>
                </table>
               

                <p>
                <div align="center" id="map" style="width: 600px; height: 400px">
                    <br />
                </div>
                </p>
            </div>
            <script type="text/javascript">
                //<![CDATA[
                if (typeof _gstat != "undefined")
                    _gstat.audience('', 'pagesperso-orange.fr');
                //]]>
            </script>
            </body>

            </html>
